//
//  _CertBitString.m
//  TestProject
//
//  Created by 武侠 on 2022/2/18.
//  Copyright © 2022 zhulong. All rights reserved.
//

#import "_CertBitString.h"

@implementation _CertBitString

- (void)loadCertData {
    char *data = (char *)self.data.bytes;
    NSString *svalue = [CertTLV value:data begin:0];
    self.value = strtoul(svalue.UTF8String, 0, 16);
}

+ (BOOL)isValid:(NSData *)data {
    if ([super isValid:data] == NO) {
        return NO;
    }
    
    char *sdata = (char *)data.bytes;
    return (uint8_t)sdata[0] == 0x03;
}

- (BOOL)bit:(int)index {
    return (self.value >> index & 0x01) == 1;
}

@end
